//
//  ReturnViewController.swift
//  CJXSwiftStoryboard
//
//  Created by CJX on 2016/10/22.
//  Copyright © 2016年 caijianxi. All rights reserved.
//

import UIKit

class ReturnViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {

    
    var myTableView = UITableView(frame: CGRect(x: 0, y: 64, width: SCREEN_WIDTH, height: SCREEN_HEIGHT-64), style: .plain)
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.creatNavVIew()
        self.creatTableView()
    }
    
    
}


extension ReturnViewController{
    
    fileprivate func creatNavVIew(){
        self.automaticallyAdjustsScrollViewInsets = false

        self.view.backgroundColor = UIColor.white
        self.navigationController?.navigationBar.barTintColor = UIColor(red: 94/255.0, green: 200/255.0, blue: 252/255.0, alpha: 1)
        self.title = "RETURN POLICY"
        
        let leftBtn = UIButton(type: .custom)
        leftBtn.setImage(UIImage(named: "nav_back"), for: UIControlState())
        leftBtn.frame = CGRect(x: 0, y: 0, width: 30, height: 30)
        leftBtn.addTarget(self, action: #selector(leftBtnClick), for: .touchUpInside)
        let item = UIBarButtonItem(customView: leftBtn)
        self.navigationItem.leftBarButtonItem = item
    }
    
    func leftBtnClick(){
        self.dismiss(animated: true) {
            
        }
    }
}

extension ReturnViewController{
    
    fileprivate func creatTableView(){
        
        myTableView.delegate = self
        myTableView.dataSource = self
        self.view.addSubview(myTableView)
        
        
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        var cell = tableView.dequeueReusableCell(withIdentifier: "cell")
        if cell == nil {
            cell = UITableViewCell(style: .default, reuseIdentifier: "cell")
        }
        let label = UILabel()
        label.font = UIFont.systemFont(ofSize: 12)
        label.numberOfLines = 0
        label.text = "Return Policy\n\nThanks for shopping at our app.\n\n1)If you are not 100% satisfied with your purchase, you can return the product and get a full refund or exchange the product for another one,be it similar or not.\n\n2)You can return a product for up to 30 days from the date you purchased it.\n\n3)Any product you return must be in the same condition you received it.Please keep the order number,you should contact us before you return the product.\n\nRefunds\n\nOnce we receive your item,we will inspect it and notify you that we have received your returned item.We will immediately notify you on the status of your refund after inspecting the item.\n\nIf your return is approved,we will initiate a refund to your credit card(or original method of payment).\n\nYou will receive the credit within a certain amount of days,depending on your card issuer’s policies.\n\nShipping\n\nYou will be responsible for paying for your own shipping costs for returning your item.\n\nShipping costs are non-refundable.If you receive a refund,the cost of return shipping will be deducted from your refund.\n\nContact Us \nIf you have any questions on how to return your item to us,contact us.\n\n"
        cell?.contentView.addSubview(label)
        if SCREEN_WIDTH == 320 {
            label.frame = CGRect(x: 20, y: 0, width: SCREEN_WIDTH-40, height: 568+250)
        }else if SCREEN_WIDTH > 320 && SCREEN_WIDTH < 430{
            label.frame = CGRect(x: 20, y: 0, width: SCREEN_WIDTH-40, height: SCREEN_HEIGHT+105)
        }else{
            label.frame = CGRect(x: 20, y: 0, width: SCREEN_WIDTH-40, height: SCREEN_HEIGHT+20)
        }
        cell?.selectionStyle = .none
        return cell!
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        if SCREEN_WIDTH == 320 {
            return 568 + 180
        }else if SCREEN_WIDTH > 320 && SCREEN_WIDTH < 430{
            return SCREEN_HEIGHT + 10
        }else{
            return SCREEN_HEIGHT
        }
    }
}








